package Cloneable;

import java.util.Hashtable;

public class PrototypeManager {
    //定义一个 Hashtable，用于存储原型对象
    private Hashtable ht=new Hashtable();
    private static PrototypeManager pm = new PrototypeManager();

    //为 Hashtable 增加公文对象
    private PrototypeManager() {
        ht.put("far",new FAR());
        ht.put("srs",new SRS());
    }

    //增加新的公文对象
    public void addOfficiaIDocument(String key,OfficiaIDocument doc) {
        ht.put(key,doc);
    }
    //通过浅克隆获取新的公文对象
    public OfficiaIDocument getOfficiaIDocument(String key) {
        return ((OfficiaIDocument)ht.get(key)).clone();
    }

    public static PrototypeManager getPrototypeManager() {
        return pm;
    }

}
